<template>
  <div class="presale_box">
    <div class="presale_item" v-for="(item, i) in info.banner" :key="i">
      <div class="presale_item_top">
        <div class="presale_item_top_left">
          <img :src="$fnc.getImgUrl(item.piclink)" alt="" />
        </div>
        <div class="presale_item_top_right">
          <p>{{ item.title }}</p>
          <div class="presale_item_top_right_middle">
            <p class="price_regular">
              <small>￥</small>
              <b>{{ get_int_dec(item.price, "int") }}</b>
              <i>{{ get_int_dec(item.price, "dec") }}</i>
              <span v-if="item.market_price && item.market_price != ''">
                {{ $fnc.toFixedZ(item.market_price || 'xx') }}
              </span>
            </p>
            <p>已售{{ $fnc.toFixedZ(item.sale_per)  }}%</p>
          </div>
          <div class="presale_item_top_right_bottom">
            <p>当前预售价格</p>

            <div class="percent_box">
              <div class="percent_left" :style="{ width: item.sale_per + '%' }"></div>
            </div>
          </div>
        </div>
      </div>
      <div class="presale_item_bottom">
        <div class="presale_item_bottom_left">
          <p>商品货期：{{ item.delivery_date | getMonthAndDay }}</p>
          <p>商品定金：{{ item.down_pay || 'xx' }}元</p>
        </div>
        <span>参与预售</span>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data () {
    return {};
  },
  props: {
    info: {
      type: Object,
      default: () => ({})
    }
  },
  components: {},
  methods: {
    get_int_dec (num, type) {
      // @type  int-整数部分 ,dec - 小数部分
      num = num + "";
      num = num.toString();
      var decimal = 2;
      decimal = decimal >= 2 && decimal < 6 ? 2 : decimal;
      decimal = decimal == "0" ? 0 : decimal || 2;
      let index = num.indexOf(".");
      if (index !== -1) {
        num = num.substring(0, decimal + index + 1);
      } else {
        num = num.substring(0);
      }
      num = parseFloat(num).toFixed(decimal);
      if (type == "int") {
        return parseInt(num);
      } else if (type == "dec") {
        return "." + num.toString().split(".")[1] || ".00";
      }else{
        return 'xx'
      }
    }
  }
};
</script>
<style lang="less" scoped>
.presale_box {
  width: 100%;
  // background-color: #f3f3f3;
  padding-bottom: 15px;
}
.presale_item {
  width: 100%;
  /* height: 140px; */
  /* padding: 10px 10px 5px 10px; */
  margin: 0 auto 10px auto;
  background-color: #ffffff;
  display: flex;
  flex-flow: column;
  justify-content: flex-start;
  align-items: center;
  border-radius: 5px;
  overflow: hidden;
}
.presale_item_top {
  width: 100%;
  height: 120px;
  padding: 10px;
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: flex-start;
}
.presale_item_top_left {
  width: 30%;
  height: 100%;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}
.presale_item_top_left img {
  width: 100%;
}
.presale_item_top_right {
  width: 70%;
  height: 100%;
  font-size: 14px;
  font-weight: bold;
  padding-left: 15px;
  display: flex;
  flex-flow: column;
  justify-content: flex-start;
}
.presale_item_top_right > p:nth-of-type(1) {
  width: 100%;
  font-size: 16px;
  color: #1a1a1a;
  line-height: 20px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;

  margin-bottom: auto;
}
.presale_item_top_right_middle {
  width: 100%;
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: flex-end;
  line-height: 30px;
  padding-top: 15px;
}
.presale_item_top_right_middle > p:nth-of-type(1) {
  font-size: 18px;
  font-weight: bold;
  color: #ff3963;
}
.presale_item_top_right_middle > p:nth-of-type(1) span {
  font-size: 12px;
  color: #999999;
  text-decoration: line-through;
}
.presale_item_top_right_middle > p:nth-of-type(2) {
  font-size: 10px;
  /* font-weight: bold; */
  color: #999999;
}
.presale_item_top_right_bottom {
  width: 100%;
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: center;
}
.presale_item_top_right_bottom > p:nth-of-type(1) {
  width: 40%;
  font-size: 12px;
  color: #ff3963;
}
.presale_item_top_right_bottom > p:nth-of-type(2) {
  width: 40%;
  font-size: 14px;
  color: #ff3963;
  display: flex;
  justify-content: center;
  align-items: center;
}
.presale_item_bottom {
  width: 100%;
  height: 50px;
  background-color: #fafafa;
  padding: 10px;
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: center;
}
.presale_item_bottom_left {
  width: 60%;
  font-size: 12px;
}
.presale_item_bottom_left p:nth-of-type(1) {
  font-size: 12px;
  color: #999999;
  /* font-weight: bold; */
}
.presale_item_bottom_left p:nth-of-type(2) {
  font-size: 12px;
  color: #999999;
}
.presale_item_bottom > span {
  font-size: 12px;
  font-weight: bold;
  color: #ffffff;
  background-color: #ff3a63;
  background: -webkit-linear-gradient(
    to left,
    #ff3a63,
    #ff7d5e
  ); /* Safari 5.1 - 6.0 */
  background: -o-linear-gradient(
    to left,
    #ff3a63,
    #ff7d5e
  ); /* Opera 11.1 - 12.0 */
  background: -moz-linear-gradient(
    to left,
    #ff3a63,
    #ff7d5e
  ); /* Firefox 3.6 - 15 */
  background: linear-gradient(to left, #ff3a63, #ff7d5e); /* 标准的语法 */
  border-radius: 10px;
  padding: 2px 20px;
  border-radius: 20px;
}
.price_regular > small {
  font-size: 10px;
  font-weight: bold;
}
.price_regular > b {
  font-size: 16px;
}
.price_regular > i {
  font-size: 10px;
  font-weight: normal;
  font-style: normal;
}
.price_regular span {
  font-weight: normal;
}

.percent_box {
  width: 50%;
  border: 1px solid #ed0e0f;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
}
.percent_left {
  /* width: 20%; */
  height: 100%;
  background-color: #ff8989;
}
</style>
